$(document).ready(function ()
{
    $(".createGame").click(function ()
    {
        //AJAX REQUEST
        $("#gameForm").submit(function (event)
        {
            event.preventDefault();

            var $form = $(this),
                currentUser = $form.find('input[name="currentUser"]').val(),
                boardgame = $form.find('select[name="boardgameSelect"]').val(),
                playerAmount = $form.find('select[name="playerSelect"]').val(),
                isPublic = $form.find('input[name="privateCheckbox"]').val();

            url = "/Game/CreateGame";
            $.post(url, { currUser: currentUser, name: boardgame, maxPlayers: playerAmount, isPublic: isPublic }, function (data)
            {
                console.log(data.username);
                window.location.replace("/Game/Lobby/" + data.id + "?user=" + data.username);
            });
        });
    });
});